<template>
  <div @click="jump()" class="box">
    <div class="left" v-if="data.images[0]">
      <img :src="data.images[0]" alt="" />
    </div>
    <div class="right">
      <p>{{ data.title }}</p>
      <span>{{ time }} 阅读 {{ data.watch || 0 }}</span>
    </div>
  </div>
</template>
<script>
import moment from 'moment'
export default {
  props: ['data'],
  computed: {
    time() {
      return moment(this.data.created_at).format('YYYY-MM-DD HH:mm')
    },
  },
  mounted() {
    // console.log(this.data)
  },
  methods: {
    jump() {
      this.$router.push('/post/detail?id=' + this.data.id)
    },
  },
}
</script>
<style lang="less" scoped>
.box {
  cursor: pointer;
  display: flex;
  padding: 15px 0;
  border-bottom: 1px solid #ddd;
  height: 80px;

  .left {
    margin-right: 10px;
    img {
      width: 100px;
      height: 80px;
      object-fit: cover;
    }
  }
  .right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    span {
      color: #999;
      font-size: 14px;
    }
  }
}
</style>